package com.leased.handler;

import com.leased.exception.DatabaseException;
import com.leased.exception.YCException;
import com.leased.request.cuser.CUserListRequest;
import com.leased.response.CarsLocationResponse;
import com.leased.service.CarsLocationService;
import com.leased.utils.YCSystemStatusEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by shencx on 2017/8/4.
 */
@Service
public class CarsLocationHandler {

    Logger LOG = LoggerFactory.getLogger(CarsLocationHandler.class);

    @Resource
    private CarsLocationService carsLocationService;

    /**
     * 获取车辆位置信息
     * @param cUserListRequest
     * @return
     * @throws YCException
     */
    public List<CarsLocationResponse> getCarsLocationList(CUserListRequest cUserListRequest) throws YCException {
        List<CarsLocationResponse> list = null;
        try {
            list = carsLocationService.fetchCarsLocationList(cUserListRequest);
            return list;
        } catch (DatabaseException e) {
            LOG.error("getCarsLocationList exception",cUserListRequest);
            throw new YCException(YCSystemStatusEnum.INVOKE_API_RETURN_EXCEPTION.getCode(), YCSystemStatusEnum.INVOKE_API_RETURN_EXCEPTION.getDesc());
        }
    }
}
